// pages/shopcar/orderStatus.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    windowHeight: 0,
    kwidth: 0,
    lists: null,
    list: null,
    dpxinxi: '',
    url: '',
    hidden3: true,
    nimei: false,
    cjjg: 0.00,
    Id: '',
    beijing_url: '/pages/images/beijing.jpg',
  },
  xxxx: function () {
    this.setData({
      nimei: true
    })
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this

    // that._loading() 
    console.log("options", options)
    if (options) {
      that.data.id = options.id
      that.setData({
        Id: options.id,
        deskid: options.deskid,
        money: options.money,
        time: options.time,
        orderstatus: options.orderstatus,
        desk_open: app.globalData.desk_open
      })
      wx.showToast({
        title: '加载中',
        icon: 'loading',
        duration: 10000
      })
      wx.request({
        url: app.globalData._new_url + 'WeChatLogin/GetOrderDetail',
        data: { orderId: options.parmid },
        method: 'post',
        success: function (res) {
          console.log(res)
          that.setData({
            list: res.data.value.orderDetails, Freight: res.data.value.Freight,
            PayStatus: res.data.value.PayStatus,
            TotalMoney: res.data.value.TotalMoney,
            ActualMoney: res.data.value.ActualMoney,
            Address: res.data.value.Address,
          })
          wx.hideToast()
        }
      })
    }
    var that = this
    var that = this
    that.setData({ urls: app.globalData._new_url, beijing_url: app.globalData.shop_infos.ShopBackgroundImage, })
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          windowHeight: res.windowHeight,
          kwidth: res.windowHeight * 0.65,
          beijing_url: app.globalData.shop_infos.ShopBackgroundImage,
          urls: app.globalData._new_url
        })
      }
    })

  },

  toPayment: function () {
    //调起微信支付
    console.log('idid', this.data.Id, app.globalData.openId)
    wx.request({
      url: app.globalData._new_url + 'MenuAPI/WeChatLogin/GetUnitOrder',
      data: { openId: app.globalData.openId, orderNumber: this.data.Id },
      method: 'POST',
      success: function (res) {
        console.log(res)
        wx.requestPayment({
          'timeStamp': res.data.value.timeStamp,
          'nonceStr': res.data.value.nonceStr,
          'package': res.data.value.package,
          'signType': res.data.value.signType,
          'paySign': res.data.value.paySign,
          success: function (res) {
            console.log(res)
          }, fail: function (err) {
            console.log(err)
          }
        })
      }
    })
  },
  onShow: function () {
    var that = this
  },


  onShareAppMessage: function () {
    return {
      title: app.globalData.dpxinxi.sname,
      path: '/pages/index/index',
      success: function (res) {
        // 分享成功
      }
    }
  },
  navToorder: function () {
    wx.switchTab({
      url: '../order/index'
    })
  },
  refresh: function () {
    this.onLoad()
  },
  navTopay: function () {
    wx.navigateTo({
      url: '../pay/index?orderNo=' + this.data.lists.orderNo + '&tableNo=' + this.data.lists.tableNo + '&totalprice=' + this.data.lists.totalprice + '&id=' + this.data.lists.id + '&type=' + this.data.lists.type
    })
  },
  chulai: function () {
    this.setData({
      hidden3: false
    })
  },
  shouqi: function () {
    this.setData({
      hidden3: true
    })
  }
})